# import the necessary packages
import cv2 as cv
import numpy as np
import argparse
import imutils

# construct the argument parser and parse the arguments
ap = argparse.ArgumentParser()
ap.add_argument("-i", "--image", required=True, help="Path to Image")
args = vars(ap.parse_args())

# load the image and show it
image = cv.imread(args["image"])
cv.imshow("Original", image)

# grab the dimensions of the image and calculate the center of the image
(h, w) = image.shape[:2]
(cX, cY) = (w / 2, h / 2)

# rotate our image by 45 degrees
M = cv.getRotationMatrix2D((cX, cY), 45, 1.0)
rotated = cv.warpAffine(image, M, (w, h))
cv.imshow("Rotated by 45 Degrees", rotated)
cv.waitKey(0)

# rotate our image by -90 degrees
M = cv.getRotationMatrix2D((cX, cY), -90, 1.0)
rotated = cv.warpAffine(image, M, (w, h))
cv.imshow("Rotated by -90 Degrees", rotated)
cv.waitKey(0)

# rotate our image around an arbitrary point rather than the center
M = cv.getRotationMatrix2D((cX - 50, cY - 50), 45, 1.0)
rotated = cv.warpAffine(image, M, (w, h))
cv.imshow("Roatated By Offset & 45 Degrees", rotated)

# finall,let's use our helper function in imutils to rotate the image by
# 180 degrees (flipping it upside down)
rotated = imutils.rotate(image, 180)
cv.imshow("Rotated by 180 Degrees", rotated)
cv.waitKey(0)
